﻿#ifndef EDITQUERYMODEL_H
#define EDITQUERYMODEL_H

#include <QSqlQueryModel>
#include <QtDebug>
#include <QSqlError>
#include <QWidget>

class editQueryModel : public QSqlQueryModel
{
    Q_OBJECT
public:
    explicit editQueryModel(QObject *parent = nullptr);
    ~editQueryModel();
    bool setData( const QModelIndex&index, const QVariant&value, int role=Qt::EditRole );
    Qt::ItemFlags flags( const QModelIndex&index ) const;
    bool deleteData( int row );
    bool addData( QString&Chinese, QString &English, QString&WordClass );
private:
    QModelIndex celldata;
    QSqlDatabase db;
    void refresh();/* 更新数据 */
    /* 设置修改接口 */
    bool setChinese( int id, const QString &Chinese );
    bool setEnglish( int id, const QString &English );
    bool setWordClass( int id, const QString &WordClass );
signals:
    void sendRefreshTable();
    void addDataFinish( bool is );
public slots:
    void saveOldData(const QModelIndex &index);
    void changeWordClassSlot( QString &WordClass );
};

#endif // EDITQUERYMODEL_H
